package com.atguigu.webapp.controller.leasaterm;

import com.atguigu.common.result.Result;
import com.atguigu.model.pojo.LeaseTerm;
import com.atguigu.webapp.service.LeaseTermService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/app/term/")
@Tag(name = "租期信息")
public class LeaseTermController {

    @Autowired
    private LeaseTermService leaseTermService;

    @GetMapping("listByRoomId")
    @Parameters({
            @Parameter(name = "id",description = "房间id",in = ParameterIn.QUERY)
    })
    @Operation(summary = "根据房间id获取可选获取租期列表")
    public Result<List<LeaseTerm>> list(@RequestParam Long id) {
        List<LeaseTerm> termList = leaseTermService.selectListByRoomId(id);
        return Result.ok(termList);
    }
}
